#include <QDebug>
#include "animatetrayicon.h"



AnimationObject::AnimationObject() :
    currentIndex(0)
{

}


const QIcon & AnimationObject::next()
{
    if(currentIndex >= size())
        currentIndex = 0;

    return at(currentIndex++);
}


AnimateTrayIcon::AnimateTrayIcon(QSystemTrayIcon *ticon, AnimationObject *anim_obj)
{
    tray = ticon;
    animationIcon = anim_obj;
    QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(animate()));
}


void AnimateTrayIcon::animate()
{
    //qWarning() << "Tray UPDATE";
    tray->setIcon( animationIcon->next() );
}


void AnimateTrayIcon::start()
{
    animate();
    timer.start(200);
}


void AnimateTrayIcon::stop()
{
    timer.stop();
}
